<?php
/**
 * 网站系统配置连接类
 * User: lhh
 * Date: 2016/8/30
 * Time: 14:44
 */
namespace Mysql;

class ShopConfigModel extends \Mysql\AbstractModel {

    /**
     * 表名
     *
     * @var string
     */
    protected $_tableName = 'cy_config';

    /**
     * 主键
     *
     * @var string
     */
    protected $_primaryKey = 'id';

    /**
     * 获取键值数组对
     * @param array $columns 返回数组键
     * @return array
     */
    public function fetchColumns($columns = array('code','value')){
        $data = $this->fetchAll($columns);
        $return_data = array();
        if(!empty($data)){
            foreach($data as $val){
                if($val['code']){
                    $return_data[$val['code']] = $val['value'];
                }
            }
        }
        return $return_data;
    }

    /**
     * 类实例

     * @var \Mysql\UserModel
     */
    private static $_instance = null;

    /**
     * 获取类实例
     *
     * @return \Mysql\UserModel
     */
    public static function getInstance() {
        if (!(self::$_instance instanceof self)) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }

}
